<?php

namespace addons\venue\controller;

use app\common\controller\Api;
use \app\admin\model\venue\feedback\Feedback as Fb;
use think\Request;

class Feedback extends Api
{
    // 无需登录的接口,*表示全部
    protected $noNeedLogin = [];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];

    protected $config = "";

    public function __construct(Request $request = null)
    {
        $this->config = get_addon_config("venue");
        parent::__construct($request);
    }

    /*
     * 添加意见反馈
     */
    public function add()
    {
        $userId = $this->auth->id;
        $tel     = $this->request->post('tel');         // 联系方式
        $content     = $this->request->post('content');         // 反馈内容
        $images     = $this->request->post('images/a')??"";         // 反馈内容
        if (!$content){
            $this->error("请输入反馈内容");
        }
        if (!$tel){
            $this->error("请输入联系方式");
        }
        if ($images){
            $images = implode(",",$images);
        }

        Fb::create([
            "user_id"=>$userId,
            "content"=>$content,
            "images"=>$images,
            "tel"=>$tel,
        ]);
        $this->success('返回成功');
    }

}
